<?php
	class UserControl extends CommonControl{

		function index (){
			$db=M('user');
			$result=$db->all();
			$this->assign('result',$result);
			$this->display();
		}

		function addusershow(){
			$this->display();
		}

		function adduser(){
			$db=M('user');
			$_POST['password']=md5($_POST['password']);
			$_POST['rpassword']=md5($_POST['rpassword']);
			$_POST['regtime']=time();
			if ($db->where("username='".$_POST['username']."'")->find()) {
				$this->error('用户名已存在');
				return false;
			}else if($_POST['password']!=$_POST['rpassword']){
				$this->error('两次密码不一致');
				return false;
			}else if($db->add()){
				$this->success('添加成功');
			}
		}

		function userdel(){
			$db=M('user');
			$userid=$_GET['uid'];
			if ($db->del($userid)) {
				$this->success('删除用户成功');
			}else{
				$this->error('删除失败，请重试');
			}
		}
	}
?>